package sing.rabbit.consumer.usage;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;

@Component
public class DirectQueueListener implements ChannelAwareMessageListener {

    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        String msg = new String(message.getBody());
        System.out.println(" [x] Received '" + msg + "'");
        //手动确认
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }

}
